document.addEventListener('DOMContentLoaded', () => {
  const tokenDiv = document.getElementById('token');
  const copyBtn = document.getElementById('copyBtn');

  // 从存储中获取最新token
  chrome.storage.local.get(['token'], (result) => {
    if (result.token) {
      tokenDiv.textContent = result.token;
    }
  });

  // 复制功能
  copyBtn.addEventListener('click', () => {
    const token = tokenDiv.textContent;
    navigator.clipboard.writeText(token).then(() => {
      copyBtn.textContent = "Copied!";
      setTimeout(() => {
        copyBtn.textContent = "Copy Token";
      }, 2000);
    });
  });
});
